package com.shouxin.attendance.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import com.shouxin.attendance.database.dao.BabyCustodyDao;
import com.shouxin.attendance.database.dao.BabyDao;
import com.shouxin.attendance.database.dao.ClazzDao;
import com.shouxin.attendance.database.dao.CustodyDao;
import com.shouxin.attendance.database.dao.DaoMaster;
import com.shouxin.attendance.database.dao.DaoSession;
import com.shouxin.attendance.database.dao.PushDataDao;
import com.shouxin.attendance.database.dao.SwipeCardHistoryDao;

public final class DBHelper {

    private static DBHelper instance = new DBHelper();
    private DaoSession daoSession;

    private DBHelper() {

    }

    public static DBHelper getInstance() {
        return instance;
    }

    public void initDB(Context context, Object dbName) {
        context = context.getApplicationContext();
        SQLiteOpenHelper helper = new SQLiteOpenHelper(context, "attendance_" + dbName, null);
        SQLiteDatabase db = helper.getWritableDatabase();
        DaoMaster daoMaster = new DaoMaster(db);
        daoSession = daoMaster.newSession();
    }

    public BabyDao getBabyDao() {
        return daoSession.getBabyDao();
    }

    public PushDataDao getPushDataDao() {
        return daoSession.getPushDataDao();
    }

    public SwipeCardHistoryDao getSwipeCardHistoryDao() {
        return daoSession.getSwipeCardHistoryDao();
    }

    public CustodyDao getCustodyDao() {
        return daoSession.getCustodyDao();
    }

    public ClazzDao getClazzDao() {
        return daoSession.getClazzDao();
    }

    public BabyCustodyDao getBabyCustodyDao() {
        return daoSession.getBabyCustodyDao();
    }
}
